package com.example.xm.ui.home.fragments.video_fragments;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.example.xm.R;
import com.example.xm.bean.HomeBean.HomeVideoBean;
import com.example.xm.customizing.PlayVideo;
import com.example.xm.utiles.TVUtils;


import butterknife.BindView;
import butterknife.ButterKnife;

public class PlayHomeVideFragment extends Fragment {

    @BindView(R.id.video)
    PlayVideo video;
    @BindView(R.id.img_back)
    ImageView imgBack;
    @BindView(R.id.img_shared)
    ImageView imgShared;
    @BindView(R.id.txt_live)
    TextView txtLive;
    @BindView(R.id.txt_comment)
    TextView txtComment;
    @BindView(R.id.img_head)
    ImageView imgHead;
    @BindView(R.id.img_level)
    ImageView imgLevel;
    @BindView(R.id.layout_head)
    RelativeLayout layoutHead;
    @BindView(R.id.txt_username)
    TextView txtUsername;
    private HomeVideoBean.DataBean.ListBean listBean;

    public static PlayHomeVideFragment getInstance(HomeVideoBean.DataBean.ListBean bean) {
        PlayHomeVideFragment playHomeVideFragment = new PlayHomeVideFragment();
        playHomeVideFragment.listBean = bean;
        return playHomeVideFragment;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View inflate = inflater.inflate(R.layout.home_video_activity_item, null);
        ButterKnife.bind(this, inflate);
        return inflate;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        if (listBean != null) {
            TVUtils.setText(txtLive, listBean.getLikeNumber());
            TVUtils.setText(txtComment, listBean.getCommentNumber());
            if (!TextUtils.isEmpty(listBean.getVideoPath())) {
                video.setUp(listBean.getVideoPath(), listBean.getTitle());
            }
        }
    }
}



